from typing import Optional, List, Any

from pydantic import BaseModel, Field, Json


class NoPaginationParams(BaseModel):
    pageSize: int = Field(default=20, description="每页数量")
    sorter: Optional[Json] = Field(default={}, description="排序字段")
    filter: Optional[Json] = Field(default={}, description="搜索条件")


class PaginationParams(NoPaginationParams):
    current: int = Field(default=1, ge=0, description="当前页码, 从1开始计算")


class PaginationViewSchema(BaseModel):
    data: Optional[List[Any]] = Field(default=None, alias="data", title="数据")
    total: Optional[int] = Field(default=0, title="总数量")
    pageSize: Optional[int] = Field(default=0, title="每页数量")
